// 调用数据接口
+ function() {
    var CommonSucceed = AjaxComplete(1);
    CommonBarNotify();
}();
//    搜索框获取失去焦点事件；
inputFn($(".my_address .my_address_form #my_address_name input"));
inputFn($(".my_address .my_address_form .inTelno input"));
//inputFn($(".my_address .my_address_form .inshortNo input"));
inputFn($(".my_address .my_address_form .inEmail input"));
inputFn($(".my_address .my_address_form .inDetail input"));
//    获取人员信息；
//function getNameFn(curterm,curdomain){
//    //    判断数据类型;
//    var obj;
//    if(curterm){
//        term:curterm
//    }else if(curdomain){
//        domain:curdomain
//    }
//    RequestGTMC("getAppUser",obj,
//        function(data){
//            console.log('获取人员信息  成功');
//            console.log(data);
//            var str,$el=$('#my_address_name');
//            if(data.length!==0){
//                str += '<span>服务联系人：</span><input type="text" data-val="请输入联系人" value="请输入联系人"/><small class="sub"></small><span class="options"><span class="optionBox">';
////                console.log(data[0].name,data[0].fullname)
//            }
//            
//        },
//        function(){
//            console.log('获取人员信息  失败')
//        },
//        function(){
//            console.log('获取人员信息  完成')
//        }
//    );
//}
function addressfn(){
    //    获取服务地址    list;
    RequestGTMC("listReqAddress", {},
        function(data) {
            console.log("服务已存 获取成功");
            console.log("列表数据：",data.data);
            var data=data.data;
            var str="",$el=$('#myAddress_address_cont');
            $el.empty();
            if (data.length !== 0) {
                if (data.length >= 10) {
                    $('.my_address .my_address_but').addClass('greyBtn');
                }
                //                $('.my_address_ftit .my_address_ftitr').data('user',data[0].cusUserName)
                $el.empty();
                str += '<dt><span class="my_address_per">服务联系人</span><span class="my_address_meth">服务联系方式</span><span class="my_address_add">服务详细地址</span><span class="my_address_hand">操作</span></dt>';
                for (var i = 0; i < data.length; i++) {
                    str += '<dd><form data-id="' + data[i].id + '"><div class="my_address_per" data-user="' + data[i].cusUserName + '">' + data[i].cusUserName + '</div><div class="my_address_meth">';
                    if (data[i].telno && data[i].telno !== "") {
                        str += '<p class="telno">' + data[i].telno + '</p>';
                    };
                    if (data[i].email && data[i].email !== "") {
                        str += '<p class="email">' + data[i].email + '</p>';
                    };
//                  if (data[i].shortNo && data[i].shortNo !== "") {
//                      str += '<p class="short">' + data[i].shortNo + '</p>';
//                  };
                str += '<i class="addBtn">+</i><i class="disBtn">-</i></div><div class="my_address_add" data-address="' + (data[i].addressId ? data[i].addressId : "") + '">' + data[i].address + '</div><div class="my_address_hand"><input type="submit" value="提交" /><span class="my_address_alter">修改</span><span class="my_address_del">删除</span><span class="' + (data[i].isDefault == "false" ? "my_address_def" : "my_address_def on") + '">默认地址</span></div></form></dd>';
                }
            }
            $el.append(str);
            AddDoneCount();
            // 事件绑定
//- function() {
            //修改已有默认地址选中效果
            $('.my_address .my_address_list .my_address_def').click(function() {
                if($(this).hasClass("greyBtn")){
                    return false;
                }else{
                    $('.my_address .my_address_list .my_address_def').removeClass('on');
                    $(this).addClass('on');
                    var defid=$(this).closest('form').data("id");
                    RequestGTMC("reqAddressSaveOrUpdate",{
                            id:$(this).closest('form').data("id"),
                            address:$(this).parent().siblings(".my_address_add").text(),
                            addressId:$(this).parent().siblings(".my_address_add").data("address"),
                            cusUserName:$(this).parent().siblings(".my_address_per").text(),
                            telno:$(this).parent().siblings(".my_address_meth").find(".telno").text(),
                            isDefault:true
                        },
                        function(data) {
                            console.log("修改默认值 成功")
                        },
                        function() {
                            console.log("修改默认值 失败")
                        },
                        function() {
                            console.log("修改默认值 完成")
                        }
                    )
                };
            })
            //删除地址
            $('.my_address .my_address_hand .my_address_del').click(function() {
                if($(this).hasClass("greyBtn")){
                    return false;
                }else{
                    var $this=$(this)
                    $('.common_shadow').stop().fadeIn().addClass("activate")
                    $('.myaddress_popup_report').stop().fadeIn().removeClass('green');
                    $('.myaddress_popup_report .back .clo').addClass('dis');
                    $('.myaddress_popup_report .tips .no').addClass('on');
                    $('.myaddress_popup_report .tips .yes').removeClass('on');
                    $('.myaddress_popup_report .tips .word').text("是否删除该联系方式?").removeClass("green");
                    $('.myaddress_popup_report .back .no').removeClass("dis")
                    $('.myaddress_popup_report .back .yes').removeClass("dis")
                    $('.myaddress_popup_report .back .yes').click(function(){
                        $('.myaddress_popup_report .back .no').addClass("dis")
                        $('.myaddress_popup_report .back .yes').addClass("dis")
                        $('.myaddress_popup_report .back .clo').removeClass("dis")
                        $('.myaddress_popup_report .tips .gif').addClass('on');
                        $('.myaddress_popup_report .tips .no').removeClass('on');
                        var id=$this.closest('form').data('id');
                        //    console.log(id)
                        RequestGTMC("deleteReqAddress", {
                                id:id
                            },
                            function(data){
                                console.log("服务地址 删除成功");
                                $('.myaddress_popup_report .tips .yes').addClass('on');
                                $('.myaddress_popup_report .tips .gif').removeClass('on');
                                $('.myaddress_popup_report .tips .word').text("该服务地址已删除！").addClass('green');
                                $('.myaddress_popup_report').addClass('green');
                                $('.myaddress_popup_report .back .clo').click(function(){
                                    $('.common_shadow').delay(200).stop().fadeOut()
                                    $('.myaddress_popup_report').delay(200).stop().fadeOut();
                                    var add_sum = $('.my_address .my_address_list dd').size();
                                    $('.my_address .my_address_sum span').eq(0).text(add_sum);
                                    $('.my_address .my_address_sum span').eq(1).text(10 - add_sum);
                                    if(add_sum<10){
                                            $('.my_address .my_address_but').removeClass("greyBtn");
                                    }
                                });
                            },
                            function(){
                                console.log("服务地址 删除失败");
                            },
                            function(){
                                console.log("服务地址 删除完成");
                                $this.parent().parent().parent().remove();
                            }
                        );
                        var add_sum = $('.my_address .my_address_list dd').size();
                        $('.my_address .my_address_sum span').eq(0).text(add_sum);
                        $('.my_address .my_address_sum span').eq(1).text(10 - add_sum);
                    });
                    $('.myaddress_popup_report .back .no').click(function(){
                        $('.common_shadow').fadeIn().removeClass("activate")
                        $('.myaddress_popup_report').fadeOut();
                    });
                }
                
               });
//               $(el).addClass("greyBtn");
               $('.my_address .my_address_list .my_address_alter').click(function(){
                   //    编辑前必须先提交；其他按钮不能点击；
                if($(this).hasClass("greyBtn")){
                    return false;
                }else{
                    //    取消按钮显示;
                    $('.my_address .my_address_cancel').show();
                    $(this).siblings('.my_address_del').addClass("greyBtn");
                    $(this).siblings('.my_address_def').addClass("greyBtn");
                    $(this).closest("dd").siblings('dd').find(".my_address_alter").addClass("greyBtn");
                    $(this).closest("dd").siblings('dd').find(".my_address_del").addClass("greyBtn");
                    $(this).closest("dd").siblings('dd').find(".my_address_def").addClass("greyBtn");
                    $(".my_address_ftitle").text("修改服务地址");
                    var _this=$(this);
                    $('.my_address .my_address_cancel').click(function(){
                        $('.my_address .my_address_hand input[type="submit"]').hide();
                        $('.my_address .my_address_sub').hide();
                        $('.my_address .my_address_alter').show();
                        $('.my_address .my_address_alter').removeClass('greyBtn');
                        $('.my_address .my_address_list dd').removeClass('grey');
                        $('.my_address .my_address_fcon').hide("fast");
                        $('.my_address .my_address_del').removeClass("greyBtn");
                        $('.my_address .my_address_def').removeClass("greyBtn");
                        $('.my_address .my_address_fcon label .my_address_warning').removeClass('on');
                        $(".my_address_form .my_address_fcon").attr("data-id","");
                        $(".my_address #my_address_address .iptFirst").val("");
                        $(".my_address #my_address_address .iptFirst").attr("data-addrid","");
                        $(".my_address #my_address_address .iptSecond").val("");
                        $(".my_address #my_address_address .iptSecond").attr("data-addrid","");
                        $(".my_address #my_address_address input").addClass("dis");
                        $(".my_address #my_address_address small").addClass("dis");
                    });
                    //    添加背景色；
                    $(this).closest('dd').addClass("grey");
                    //    先清空input 的值
                    $(".my_address_form .my_address_fcon #my_address_name").find("input").val("");
                    $(".my_address_form .my_address_fcon .inTelno").find("input").val("")
                    $(".my_address_form .my_address_fcon .inEail").find("input").val("")
//                  $(".my_address_form .my_address_fcon .inshortNo").find("input").val("");
                    $(".my_address_form .my_address_fcon").attr("data-id","");
                    $('.my_address_dlr .my_address_fcon .inDetail p').text("");
                    $('.my_address_dlr .my_address_fcon .inDetail p').attr("data-pathid","");
//                  $(".my_address #my_address_address .iptFirst").val("");
//                  $(".my_address #my_address_address .iptFirst").attr("data-addrid","");
//                  //    服务地址都隐藏；
//                  $(".my_address #my_address_address input").addClass("dis");
//                  $(".my_address #my_address_address small").addClass("dis");
                    //    编辑btn 隐藏；
                    $('.my_address .my_address_ftitr .my_address_but').hide();
                    //    联系人值
                    $(".my_address_form .my_address_fcon #my_address_name").find("input").val($(this).parent().siblings(".my_address_per").text());
                    //    联系方式值
                    $(".my_address_form .my_address_fcon .inTelno").find("input").val($(this).parent().siblings(".my_address_meth").find(".telno").text());
                    var emailN = $(this).parent().siblings(".my_address_meth").find(".email").text() ? $(this).parent().siblings(".my_address_meth").find(".email").text() : $(".my_address_form .my_address_fcon .inEmail").find("input").data('txt');
                    $(".my_address_form .my_address_fcon .inEmail").find("input").val(emailN);
//                  var shortN = $(this).parent().siblings(".my_address_meth").find(".short").text() ? $(this).parent().siblings(".my_address_meth").find(".short").text() :  $(".my_address_form .my_address_fcon .inshortNo").find("input").data('txt');
//                  $(".my_address_form .my_address_fcon .inshortNo").find("input").val(shortN);
                    //    id值
                    $(".my_address_form .my_address_fcon").attr("data-id",$(this).closest("form").attr("data-id"));
                    $('.my_address_dlr .my_address_fcon .inDetail p').text($(this).parent().siblings(".my_address_add").text())
                    $('.my_address_dlr .my_address_fcon .inDetail p').attr("data-pathid",$(this).parent().siblings(".my_address_add").attr("data-address"));
                    if($(this).siblings('.my_address_def').hasClass('on')){
                    	$('.my_address .my_address_check span').addClass('on');
                    }else{
                    	$('.my_address .my_address_check span').removeClass('on');
                    }
                    if($('#my_address_name input')!=="" && $('#my_address_name input')!==$('#my_address_name input').data('txt')&& !$(".my_address .my_address_fcon .inTelno .my_address_warning").hasClass('on')){
						$(".my_address .my_address_form .my_address_sub").removeClass('greyBtn');
					}else{
						$(".my_address .my_address_form .my_address_sub").addClass('greyBtn');
					}
                    //    修改按钮 隐藏
                    $(this).hide();
                    //    提交按钮 显示
                    $('.my_address .my_address_sub').show();
                    $('.my_address .my_address_fcon').show("fast");
                    //    编辑的个数；
                    $('.my_address .my_address_sum').show();
                    var add_sum = $('.my_address .my_address_list dd').size();
                    $('.my_address .my_address_sum span').eq(0).text(add_sum);
                    $('.my_address .my_address_sum span').eq(1).text(10 - add_sum);
    //                $(".my_address .my_address_form .my_address_sub").addClass('greyBtn');
                    $(this).parent().find('input[type=submit]').css('display', 'inline-block');
                    $('.my_address .my_address_cancel').click(function() {
                        $(this).hide();
                        $(this).siblings('.my_address_sub').hide();
                        $(this).siblings('.my_address_but').show();
                        $(".my_address_form .my_address_fcon #my_address_name").find("input").val("");
                        $(".my_address_form .my_address_fcon .inTelno").find("input").val("")
                        $(".my_address_form .my_address_fcon .inEail").find("input").val("")
//                      $(".my_address_form .my_address_fcon .inshortNo").find("input").val("");
                        $(".my_address_form .my_address_fcon").attr("data-id", "");
                        $(".my_address #my_address_address .iptFirst").val("");
                        $(".my_address #my_address_address .iptFirst").attr("data-addrid", "");
                        $(".my_address #my_address_address input").addClass("dis");
                        $(".my_address #my_address_address small").addClass("dis");
                        $('.my_address .my_address_fcon').hide("fast");
                        //    编辑的个数；
                        $('.my_address .my_address_sum').hide();
                        $('.my_address .my_address_list form input[type=submit]').css('display', 'none');
                        $('.my_address .my_address_del').removeClass('greyBtn');
                        $('.my_address .my_address_def').removeClass('greyBtn');
                        $('.my_address .my_address_alter').css('display', 'inline-block');
                        $('.my_address .my_address_list dd').removeClass('on').removeClass('greyBtn');
                        $(".my_address_form .my_address_fcon").attr("data-id", "");
                    });
                }
           })
                //    列表栏的提交按钮点击事件；
             $('.my_address_list form input[type=submit]').click(function(){
                 $(this).hide();
                 $('.my_address .my_address_sub').trigger("click");
                   $(this).siblings('.my_address_alter').show();
                $(this).parent().siblings().find('p span').show();
                $(this).parent().siblings().find('input').hide();
             });
            
            //添加新增联系方式2017/11/09  改为全部显示
        },
        function() {
            console.log("服务已存 调用失败");
        },
        function() {
            console.log("服务已存 请求完成");
        }
    );
};
//获取服务地址 函数
addressfn();

(function(){
	// 有查名称
	function HasUserNameQuery() {
	    var $el = $('#my_address_name input');
	    if ($el.length > 0) {
	        // 插入弹框和改变事件
	        $el.parent().css('position', 'relative').append('<div class="form_fuzzy_query"></div>');
	        $el.on('input propertychange', function(event) {
//	            console.log('input' + $(this).val().trim() + 'propertychange');
	            if ($(this).val() !== undefined && $(this).val().trim() !== "") {
	            var $op = $(this).siblings('.form_fuzzy_query');
	            $op.css({'left':'93px','top':'32px'})
	            RequestGTMC("listAppUserByTerm", {
	                    term: $(this).val(),
                    	domain:"DLR"
	                },
	                function(json) {
	                    console.log("名称下拉 查询成功", json);
	                    if (json.length > 0) {
	                        var str = '<dl>';
	                        for (var i = 0; i < json.length; i++) {
	                            str += '<dd data-mobile="' + json[i].mobile + '" data-name="' + json[i].fullname + '" data-email="' + json[i].email + '" data-path="'+(json[i].department_treenode_name_path == null ? "" : json[i].department_treenode_name_path )+'" data-pathid="'+(json[i].app_department_id == null ? "" : json[i].app_department_id )+'">' + json[i].name + ' ' + json[i].fullname + '</dd>';
	                        }
	                        str += '</dl>';
	                        // 填数据和显示
	                        $op.html(str).show();
	                        console.log($op.find('dd'));
	                        // 点击事件
	                       
	                        $op.find('dd').on('click', function(event) {
	                        	 
	                            // 对选项做判断
	                            var	thisemail = $(this).attr('data-email');
	                            var thismobile = $(this).attr('data-mobile');
//	                            var thisshort = $(this).attr('data-short');
	                            var thispath = $(this).attr('data-path');
                            	var thispathid = $(this).attr('data-pathid');
                            	var thisname = $(this).attr('data-name');
                            	
                            	$('#my_address_name input').val(thisname);
//	                            console.log(thisemail,thisemail.length,thismobile !== "无" && thismobile !==" null" && thismobile.length>0)
	                            if(thismobile !== "无" && thismobile !==" null" && thismobile.length>0){
	                            	$('.my_address .my_address_fcon .inTelno input').val(thismobile);
	                            	if($('.my_address .my_address_fcon .inTelno').is(".inTelno")&&/^1[34578]\d{9}$/.test($('.my_address .my_address_fcon .inTelno input').val())){
							            $(".my_address .my_address_fcon .inTelno .my_address_warning").removeClass("on");
							        }else if($('.my_address .my_address_fcon .inTelno').is(".inTelno")&&!(/^1[34578]\d{9}$/.test($('.my_address .my_address_fcon .inTelno input').val()))){
							            $(".my_address .my_address_fcon .inTelno .my_address_warning").addClass("on");
							        };
	                            }
	                            if(thisemail !== "无" && thisemail !==" null" && thisemail.length>0){
	                            	$('.my_address .my_address_fcon .inEmail input').val(thisemail);
	                            }
//	                            if(thisshort !== "无" && thisshort !==" null" && thisshort.length>0){
//	                            	$('.my_address .my_address_fcon .inshortNo input').val(thisshort);
//	                            }
	                            if(thispath !== "无" && thispath !==" null" && thispath.length>0){
                            		$('.my_address .my_address_fcon .inDetail p').text(thispath);
	                            };
	                            if(thispathid !== "无" && thispathid !==" null" && thispathid.length>0){
	                            	$('.my_address .my_address_fcon .inDetail p').attr("data-pathid",thispathid);
	                            };
	                            $op.stop().removeAttr('style');
	                            $('.my_address_fcon').find('input[type="text"]').blur(function(){
									$('.my_address_fcon').find('input[type="text"]').trigger("input propertychange");
								});
								if($('#my_address_name input')!=="" && $('#my_address_name input')!==$('#my_address_name input').data('txt')&& !$(".my_address .my_address_fcon .inTelno .my_address_warning").hasClass('on')){
									
									$(".my_address .my_address_form .my_address_sub").removeClass('greyBtn');
								}else{
									$(".my_address .my_address_form .my_address_sub").addClass('greyBtn');
								}
	                        });
	                        // 移入事件
	                        $op.find('dd').on('mouseenter', function(event) {
	                            $(this).addClass('activate').siblings().removeAttr('class');
	                        });
	                        // 移出事件
	                        $op.find('dd').on('mouseleave', function(event) {
	                            $(this).removeClass('activate');
	                        });
	                    } else {
	                        $op.removeAttr('style').empty();
	                    }
	                });
	            }
	        });
	        // 失焦事件
	        $el.on('blur', function(event) {
	            if ($(this).siblings('.form_fuzzy_query').find('.activate').length === 0) {
	                $(this).siblings('.form_fuzzy_query').stop().removeAttr('style');
	            }
	        });
	    }
	}
	HasUserNameQuery();
    var thistype = GetUrlParam("type"),
        thistier = GetUrlParam("tier");
    if (thistype && thistier) {
        $('.common_float').prepend('<a href="detail.html?type=' + thistype + '&tier=' + thistier + '" class="lbtn2">返回表单</a>')
        $('.common_shadow').addClass('activate').children('.myaddress_popup_tips').addClass('activate');
        $(".myaddress_popup_tips .back a").on('click', function(event) {
            $('.common_shadow').removeClass('activate').children('.myaddress_popup_tips').removeClass('activate');
        });
    }
    //点击右上角取消按钮；
    $('.my_address .my_address_cancel').click(function(){
        var $ipt=$('.my_address_fcon').find('input[type="text"]');
        $ipt.first().val($ipt.first().data('txt'));
        $ipt.last().val($ipt.last().data('txt'));
        $ipt.eq(3).val($ipt.eq(3).data('txt'));
        $ipt.eq(2).val($ipt.eq(2).data('txt'));
        $ipt.eq(1).val($ipt.eq(1).data('txt'));
        $('.my_address .my_address_check span').removeClass('on');
        $(".my_address_ftitle").text("新增服务地址");
        $(this).hide();
        $('.my_address .my_address_sub').hide();
        $('.my_address .my_address_but').show();
        $('.my_address .my_address_fcon').hide("fast");
        $('.my_address .my_address_sum').hide();
    })
    //点击右上角编辑按钮;
    $('.my_address .my_address_but').click(function(address,id) {
        //    判断服务地址列表个数；显示页面弹框；
        if($(this).hasClass("greyBtn")){
            $('.common_shadow').addClass("activate");
            $('.common_shadow').fadeIn();
            $('.myaddress_popup_warning').fadeIn();
            //    弹框显示并自动隐藏；
            $('.common_shadow').delay(3000).fadeOut();
            $('.myaddress_popup_warning').delay(3000).fadeOut();
        }else{
            console.log(address,id)
            //    点击右上角编辑按钮，获取列表地址；
            $(this).hide();
            $('.my_address .my_address_sub').show();
            $('.my_address .my_address_cancel').show();
            $('.my_address .my_address_fcon').show("fast");
            $('.my_address .my_address_sum').show();
            var add_sum = $('.my_address .my_address_list dd').size();
            $('.my_address .my_address_sum span').eq(0).text(add_sum);
            $('.my_address .my_address_sum span').eq(1).text(10 - add_sum);
            $(".my_address .my_address_form .my_address_sub").addClass('greyBtn');
            //左右边栏高度设置
            var H = $('.my_address .my_address_rcon').height();
            if (H > 500) {
                $('.my_address .my_address_lcon').height(H - 25);
            }
        }
    });

    //    check 选中状态
    var iptFlag=false;
    //新增默认地址选中效果
//    var defaultObj = {};
    $('.my_address .my_address_check span').click(function() {
        if ($(this).hasClass('on')) {
            $(this).removeClass('on');
            iptFlag=false;
        } else {
            $(this).addClass('on');
            iptFlag=true;
        }
        newObj["flag"]=iptFlag;
        return false;
    });
    $('.my_address .my_address_check i').click(function(){
        $('.my_address .my_address_check span').trigger("click");
    })
    //    新增数据的obj对象；
    var newObj={};
    newObj["flag"] = iptFlag;
//  console.log("是否是默认值",newObj.flag)
    $('.my_address_fcon').find('input[type="text"]').on("input propertychange",function(event){
        var $ipt=$('.my_address_fcon').find('input[type="text"]');
        var $telNo=$('.my_address_fcon').children('.inTelno').children('input');
        var $emailNo=$('.my_address_fcon').children('.inEmail').children('input');
//      var $shortNo=$('.my_address_fcon').children('.inshortNo').children('input');
        newObj["cusUserName"]=$ipt.first().val();
        newObj["cusUserId"]=$("#common_myself_name").data('id');
        newObj["creatorName"]=$ipt.first().val();
        
        newObj["telno"]=$ipt.eq(1).val();
//      console.log($(this).closest("label").is(".inTelno"))
        if($(this).closest("label").is(".inTelno")&&/^1[34578]\d{9}$/.test($ipt.eq(1).val())){
            $(".my_address .my_address_fcon .inTelno .my_address_warning").removeClass("on");
        }else if($(this).closest("label").is(".inTelno")&&!(/^1[34578]\d{9}$/.test($ipt.eq(1).val()))){
            $(".my_address .my_address_fcon .inTelno .my_address_warning").addClass("on");
        };
        $(".my_address .my_address_fcon .inEmail input").blur(function(){
            if($ipt.eq(2).val() == $ipt.eq(2).data('txt')){
                $ipt.eq(2).siblings(".my_address_warning").removeClass("on");
            }
        });
//      $(".my_address .my_address_fcon .inshortNo input").blur(function(){
//          if($ipt.eq(3).val() == $ipt.eq(3).data('txt')){
//              $ipt.eq(3).siblings(".my_address_warning").removeClass("on");
//          }
//      });
        if($(this).closest("label").is(".inEmail")&&(/^[\w-]+(\.[\w-]+)*@[\w-]+(\.[\w-]+)+$/.test($ipt.eq(2).val()))){
            $ipt.eq(2).siblings(".my_address_warning").removeClass("on");
        }else if($(this).closest("label").is(".inEmail")&&!(/^[\w-]+(\.[\w-]+)*@[\w-]+(\.[\w-]+)+$/.test($ipt.eq(2).val()))){
            $ipt.eq(2).siblings(".my_address_warning").addClass("on");
        };
//      if($(this).closest("label").is(".inshortNo")&&(/^\d{3,6}$/.test($ipt.eq(3).val()))){
//          $ipt.eq(3).siblings(".my_address_warning").removeClass("on");
//      }else if($(this).closest("label").is(".inshortNo")&&!(/^\d{3,6}$/.test($ipt.eq(3).val()))){
//          $ipt.eq(3).siblings(".my_address_warning").addClass("on");
//      }
        if((newObj.cusUserName!==""&&newObj.cusUserName!==$ipt.first().data('txt'))&&(newObj.telno!==""&&newObj.telno!==$telNo.data("txt"))&&!$(".my_address_warning").hasClass("on")){
            $(".my_address .my_address_form .my_address_sub").removeClass('greyBtn');
        }else{
            $(".my_address .my_address_form .my_address_sub").addClass('greyBtn');
        }
    });
 	
    //点击保存按钮
    $('.my_address .my_address_sub').click(function() {
        if($(this).hasClass("greyBtn")){
//            alert("不能提交")
            return false;
        }else{
            var $ipt=$('.my_address_fcon').find('input[type="text"]');
            var strings = $ipt.eq(4).val();
            newObj["cusUserName"]=$ipt.first().val();
            newObj["telno"]=$ipt.eq(1).val();
            if(!$ipt.eq(5).hasClass("dis")){
                strings += "-" + $ipt.eq(5).val();
            };
            if(!$ipt.eq(6).hasClass("dis")){
                strings +="-" + $ipt.eq(6).val();
            }
            if($ipt.eq(3).val() == $ipt.eq(3).data('txt')){
                console.log("asdjgngkfndfk")
                $ipt.eq(3).val("");
                
            }
//          newObj["shortNo"]=$ipt.eq(3).val();
            if($ipt.eq(2).val() == $ipt.eq(2).data('txt')){
                $ipt.eq(2).val("");
                
            }
            newObj["email"]=$ipt.eq(2).val();
            if($ipt.last().val() == $ipt.last().data('txt')){
                $ipt.last().val("");
            }
			newObj["address"] = $('.my_address_dlr .my_address_fcon .inDetail p').text();
			newObj["addressId"] = $('.my_address_dlr .my_address_fcon .inDetail p').attr("data-pathid");
            newObj["id"]=$(".my_address .my_address_fcon").attr('data-id');
            RequestGTMC("reqAddressSaveOrUpdate", {
                id:newObj.id||null,
                address:newObj.address,
                addressId:newObj.addressId,
                cusUserName:newObj.cusUserName,
                telno:newObj.telno,
                email:newObj.email||null,
//              shortNo:newObj.shortNo||null,
                isDefault:newObj.flag,
                addressDetail:newObj.addressDetail||null
                },
                function(data){
                    console.log('添加 成功');
                    $ipt.first().val($ipt.first().data('val'));
                    $ipt.last().val($ipt.last().data('val'));
                    $ipt.eq(3).val($ipt.eq(3).data('val'));
                    $ipt.eq(2).val($ipt.eq(2).data('val'));
                    $ipt.eq(1).val($ipt.eq(1).data('val'));
                    $('.my_address_dlr .my_address_fcon .inDetail p').text("");
                    $('.my_address_dlr .my_address_fcon .inDetail p').attr("data-pathid","");
                    $('.my_address .my_address_check span').removeClass('on');
                    $('.my_address .my_address_list .my_address_alter').removeClass("greyBtn");
                    $('.my_address .my_address_list .my_address_def').removeClass("greyBtn");
                    $('.my_address .my_address_list .my_address_del').removeClass("greyBtn");
                    $(".my_address_ftitle").text("新增服务地址");
                    //    去除背景色；
                    $(this).closest('dd').removeClass("grey");
                    addressfn();
                
                    if(newObj.id!==""){
                        $(".my_address_form .my_address_fcon").attr("data-id","");
                    }
                },
                function(){
                    console.log('添加 失败');
                },
                function(){
                    console.log('添加 完成');
                }
               );
            $(this).hide();
            $(this).siblings('.my_address_cancel').hide();
            $('.my_address .my_address_but').show();
            $('.my_address .my_address_fcon').hide("fast");
            $('.my_address .my_address_sum').hide();
            var add_sum = $('.my_address .my_address_list dd').size();
            $('.my_address .my_address_sum span').eq(0).text(add_sum);
            $('.my_address .my_address_sum span').eq(1).text(10 - add_sum);
            return false;
        }
    });
    // 概况表显示
    $('.common_float .lbtn1').on('click', function(event) {
        $(".common_shadow .picture_box_index").addClass('on');
        $(".common_shadow").addClass('activate');
    });
    // 概况表关闭
    $(".common_shadow .picture_box_index .close").on('click', function(event) {
        $('.common_shadow .picture_box_index .pics').scrollTop(0)
        $(this).closest('.common_shadow').removeClass('activate');
        $(this).parent('.picture_box_index').removeClass('on');
    });
})();